
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sj" tagdir="/WEB-INF/tags/spring-jquery-tags"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<link rel="stylesheet" type="text/css" href="<c:url value='/css/jquery/flexigrid.pack.css' />" />
<script type="text/javascript" src="<c:url value='/js/jquery/flexigrid.pack.js' />"></script>
<script type="text/javascript" src="<c:url value='/js/util.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/payment-line-item.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.numeric.js'/>"></script>
<script type="text/javascript" src="<c:url value='/js/jquery/jquery.formatCurrency-1.4.0.pack.js'/>"></script>
<script type="text/javascript">
    $(document).ready(
            function() {
                $('#pageTitle').text('<spring:message code="editPaymentrequest.heading.paymentReqProcessing" />');
                
               /* BLOG96 Pressing the Enter key - When the user presses the enter key
                while adding a record or editing a record, the system
                attempts to save the record...THIS SHOULD NOT OCCUR...
                causes errors.
                */
                $(':input').live('keypress', function(event) {
                    if(event.keyCode == 13) {
                        if(event.preventDefault) {
                               event.preventDefault();
                           } else {
                               // IE
                               event.returnValue = false;
                           }
                           return false;
                    }
                });
                   
                var cancelRequestedMessage = '<spring:message code="status.payment.process.cancelrequested" />';
                var statusCode = '${paymentrequest.statusCode}';
                if(cancelRequestedMessage == statusCode) {
                    $('#nextActionButton').click(function() {
                        var dialogBody = '';
                        dialogBody += 'A request to cancel this payment request has ';
                        dialogBody += 'been submitted by the originator. Do you want to cancel ';
                        dialogBody += 'the payment request, or continue processing the ';
                        dialogBody += 'payment?';
                        $('<div>' + dialogBody + '</div>').dialog({
                            modal: true,
                            height: 300,
                            width: 400,
                            buttons: 
                                  {
                                    'Cancel' : function() {
                                        var nextactionValue = '<spring:message code="editPaymentrequest.label.prCancel" />';
                                        var nextactionname = '<spring:message code="name.button.nextaction" />';
                                        $(this).dialog('close');
                                        $('#editPaymentrequestForm').append('<input type="hidden" name="' + nextactionname + '" value="' + nextactionValue + '" />');
                                        $('#editPaymentrequestForm').submit();
                                    },
                                    'Continue Processing' : function() {
                                        var nextactionValue = '<spring:message code="name.button.continuepaymentrequest" />';
                                        var nextactionname = '<spring:message code="name.button.nextaction" />';
                                        $(this).dialog('close');
                                        $('#editPaymentrequestForm').append('<input type="hidden" name="' + nextactionname + '" value="' + nextactionValue + '" />');
                                        $('#editPaymentrequestForm').submit();
                                    }
                                  },
                              close: function(event, ui) {
                                  $(this).dialog('destroy');                  
                              }
                        });
                        return false;
                    });
                }
                
                var arr_projects = new Array();
                <c:forEach items="${cipeProjects}" var="project" varStatus="status">
                    var project${status.index} = new Object();
                    project${status.index}.id = '${project.id}';
                    project${status.index}.projectId = '${project.projectId}';
                    project${status.index}.projectType = '${project.projectTypeDesc}';
                    project${status.index}.title = '${project.escapedTitle}';
                    project${status.index}.status = '${project.status}';
                    project${status.index}.region = '${project.escapedRegion}';
                    project${status.index}.country = '${project.escapedCountry}';
                    project${status.index}.acronym = '${project.escapedAcronym}';
                    project${status.index}.formattedStartDate = '${project.formattedProjectStartDate}';
                    project${status.index}.formattedEndDate = '${project.formattedProjectEndDate}';
                    project${status.index}.partnerName = '${project.escapedPartnerName}';
                    project${status.index}.override = '${project.budgetOverride}';
                    project${status.index}.remainingFunds = ${project.remainingFundsPRExcluded};
                    project${status.index}.displayName = '${project.displayName}';
                    arr_projects[${status.index}] = project${status.index};
                </c:forEach>
                var arr_account_codes = new Array();
                <c:forEach items="${accountCodes}" var="accountCode" varStatus="status">
                    var accountCode${status.index} = new Object();
                    accountCode${status.index}.id = '${accountCode.id}';
                    accountCode${status.index}.code = '${accountCode.code}';
                    accountCode${status.index}.description = '<c:out value="${accountCode.escapedDescription}" />';
                    accountCode${status.index}.displayName = '<c:out value="${accountCode.displayName}" />';
                    arr_account_codes[${status.index}] = accountCode${status.index};
                </c:forEach>
                var arr_lineItems = new Array();
                <c:forEach items="${paymentrequest.lineItemBeans}" var="item" varStatus="status">
                    var item${status.index} = new Object();
                    item${status.index}.id = '${item.id}';
                    item${status.index}.accountCodeId = '${item.accountCodeId}';
                    item${status.index}.cipeProjectId = '${item.cipeProjectId}';
                    item${status.index}.lineItemNumber = '${item.lineItemNumber}';
                    item${status.index}.prevAmount = ${item.prevAmount};
                    item${status.index}.amount = ${item.amount};
                    arr_lineItems[${status.index}] = item${status.index};
                </c:forEach>
                
                var tabIndex = parseInt($('#comments').attr('tabindex'));
                var paymentLineItem = new com.cipe.cmrs.model.PaymentLineItem('paymentLineItems', arr_projects, arr_account_codes, arr_lineItems, tabIndex, function(totalAmount) {
                    $('#amount').val(totalAmount);
                    $('#amount').formatCurrency('#amountLabel',{colorize: true, negativeFormat: '(-%s%n)'});
                });
                $('#amount').formatCurrency('#amountLabel',{colorize: true, negativeFormat: '(-%s%n)'});
                
                $.validator.addMethod("drop_down_required", function(value, element) {
                    return (value != "");
                }, "Please select an option.");
                
                $("#editPaymentrequestForm").validate({
                    rules : {
                        paymentTypeId : {
                            drop_down_required : true
                        },
                        paymentMethod : {
                            drop_down_required : true
                        },
                        payeeId : {
                            drop_down_required : true
                        },
                        purposeOfExpenditure : {
                            required : true
                        }
                    }
                });

                $('#btnSignatureSelection').click(function() {
                    window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
                });
                
                $('#btnOutstandingWireTransfers').click(function() {
                    window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
                });
                
                $('#btnOver30days').click(function() {
                    window.open("<c:url value='/report.do' />", "_blank", "left=20, top=20, width=700, height=700, toolbar=1, resizable=0").focus();
                });
                
                $('#btnSignatureAllUnpaid').click(function() {
                    window.open("<c:url value='/secure/signatureSelectionAllUnpaidPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
                });
                
                $('#printWireForm').click(function() {
                    window.open("<c:url value='/secure/showBankWireTransferPdf.do' />?paymentRequestId=" + "${paymentrequest.id}" + "&" + "beneficiaryName=" + $('#payeeDesc').val($(':selected', this).text()), "_blank").focus();
                });
                /*
                    PRV5
                    Print Payment Request' button - There should be a "dynamic button" which changes based on the 'Type' of payment request chosen.
                    1) If the Payment Request Type = "Advance" or "Consultants/Contracts" or "Staff Reimbursements" or "Vendor Invoices" the button should read 'Print Payment Request Form', and should print the standard Payment Request form.
                    2) If the Payment Request Type = "Partner Payment" the button should read 'Print Partner Payment Request Form', and should print the standard Partner Payment Request Form.
                    3) If the Payment Request Type = "Reclass/Liquidation" the button should read 'Print Reclass Form', and should print the standard ReclassForm.        
                */
                $("#paymentTypeId").change(function()
                {
                    if(this.value==1 || this.value==2 || this.value==4 || this.value==6) {
                        $('#printPaymentRequest').text('Print Payment Request Form');
                        $('#printPaymentRequest').css('display','inline');
                    }
                    else if(this.value== 3) {
                        $('#printPaymentRequest').text('Print Partner Payment Request Form');
                        $('#printPaymentRequest').css('display','inline');
                    } else if(this.value == 5){
                        $('#printPaymentRequest').text('Print Reclass Form');
                        $('#printPaymentRequest').css('display','inline');
                    } else {
                        $('#printPaymentRequest').css('display','none');
                    }
                });
                    
                $("#paymentTypeId").change();
                
                $('#printPaymentRequest').click(function() {
                    var reportType = $('#printPaymentRequest').html();
                    if($.trim(reportType) == 'Print Payment Request Form') {
                        window.open("<c:url value='/secure/printPaymentRequestFormPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
                    }
                    if($.trim(reportType) == 'Print Partner Payment Request Form') {
                        window.open("<c:url value='/secure/printPartnerPaymentRequestPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
                    }
                    if($.trim(reportType) == 'Print Reclass Form') {
                        window.open("<c:url value='/secure/printReclassFormPdf.do' />?paymentRequestId=" + "${paymentrequest.id}", "_blank").focus();
                    }
                });
                
                toggleViewEditMode(true);
                
                <c:choose>
                    <c:when test="${empty canEdit || !canEdit}">
                        toggleButtons(true,$('#editButton'));
                    </c:when>
                    <c:otherwise>                
                        toggleViewEditMode(true);
                        
                        $('#editButton').click(function() {
                            toggleViewEditMode(false);
                        });
                        
                        $('#cancelEditButton').click(function() {
                            var ans = confirm('Are you sure you want to cancel editing this record without saving it?');
                            if (ans) {
                                loadDiv('content', 'processPaymentrequest.do?id=${paymentrequest.id}');
                            }
                        });
                        
                    </c:otherwise>
                </c:choose>
            
            $('#payeeId').change(function() {
                if (this.value != '') {
                    $('#add-paymentrequest-link').val('Edit');
                    $('#payeeDesc').val($(':selected', this).text());
                    loadDataViaAjax("getPayee.do", {
                        "payeeId" : this.value
                    }, function(bean) {
                        $('#payeeAddress').val(bean.completeAddress);
                    });
                } else {
                    $('#add-paymentrequest-link').val('Add');
                    $('#payeeDesc').val('');
                    $('#payeeAddress').val('');
                }
            });
            $('#payeeId').change();
            
            $('#dummyRejectStatusButton').click(function() {
            	var htmlString = '';
            	htmlString += '<label><spring:message code="editPaymentrequest.label.reasonForRejection" />:&nbsp;</label><br/>';
          		htmlString += '<textarea id="dummyReasonRejected" style="width: 100%; height: 250px;"></textarea>';
          		var ui = $('<div id="reject-reason-container"></div>').append(htmlString);
                ui.dialog({
                    title: 'Please Enter Reason',
                    autoOpen: false,
                    width: 400,
                    modal: true,
                    resizable: false,
                    close: function(event, ui) {
        				$(this).dialog('destroy');
        			},
                    buttons: {
                        "OK": function() {
                            $(this).dialog("close");
                            var reason = $('#dummyReasonRejected').val();
                            if(reason == null || reason.trim() == "") {
                                alert("Payment Request was not rejected. You must enter a reject reason to reject the payment request.");
                            } else {
                                $('#reasonrejected').val(reason);
                                $('#reasonrejected').removeAttr('disabled');
                              	$('#rejectPaymentStatusButton').click();
                            }
                        },
                        "Cancel": function() {
                            $(this).dialog("close");
                        }
                    }
                });
                ui.dialog('open');
            });
            
            $('.cancel-button').click(function() {
                loadDiv('content', 'refreshDashboard.do');
            });

            $("#receivedFromAccountingDate").datepicker();
            $("#invoiceRequestDate").datepicker();
            $("#dateToFinanace").datepicker();

            $('.list-paymentrequest-link').click(function() {
                loadDiv('content', 'showPayeeList.do');
            });
            $('#instructions-link').click(function() {
                loadDiv('content', 'showInstructionsPaymentReq.do');
            });

            $('.close-button').click(function() {
                if(confirm('Are you sure you want to close the form?')) {
                    window.location = '../secure/showDashboard.do';
                }
             });
            
            $('#save').click(function() {
                if(paymentLineItem.has6570or6571AccountCode()) {
                    open6570VerifyDialog(function(verified) {
                        $('#sixFiveSeventyVerify').prop('checked', verified);
                        $('#doSave').click();
                    });
                } else {
                    $('#sixFiveSeventyVerify').prop('checked', false);
                    $('#doSave').click();
                }
            });
        });
        
        function open6570VerifyDialog(okListener) {
            var ID_DIALOG_CONTAINER = 'test_ID_DIALOG_CONTAINER';

            var htmlString = '<div><input id="chk6570Verify" type="checkbox" />I verify that the deliverables have been received and accepted in accordance with the terms of the contract for this payment.</div>';
            var ui = $('<div id="' + ID_DIALOG_CONTAINER + '"></div>').append(htmlString);
            ui.dialog({
                modal: true,
                autoOpen : false,
                height: 250,
                width: 300,
                close: function(event, ui) {
                    $(this).dialog('destroy');
                }
            });
            ui.dialog('option', 'buttons', {
                'OK' : function() {
                    var verified = $('#chk6570Verify').prop('checked');
                    $(this).dialog('close');
                    $('#' + ID_DIALOG_CONTAINER).remove();
                    if(okListener) {
                        okListener(verified);
                    }
                },
                'Cancel' : function() {
                    $(this).dialog('close');
                    $('#' + ID_DIALOG_CONTAINER).remove();
                }
            });
            ui.dialog('open');
        }
        
        function toggleInputOrSelectElement(viewMode,elements) {
            for(var i = 0; i < elements.length; i++) {
                elements[i].disabled = viewMode;
                elements[i].readonly = viewMode;
                var className = '';
                if(viewMode) {
                    className = 'text_grey';
                    if(elements[i].className.indexOf("input-full-width-req") != -1) {
                        className = 'input-full-width-req ' + className;    
                    }
                } else {
                    if(elements[i].className.indexOf("input-full-width-req") != -1) {
                        className += 'input-full-width-req text_blue';    
                    } else {
                        className += 'text_white';
                    }
                }
                elements[i].className = className;
            }
        }
        
        function toggleButtons(viewMode, button) {
            if(viewMode) {
                button.attr('disabled','disabled');
                button.removeClass('blue_btn');
                button.addClass('gray_btn');
            } else {
                button.removeAttr('disabled');
                button.removeClass('gray_btn');
                button.addClass('blue_btn');
            }
        }
        
        function toggleViewEditMode(viewMode) {
            var inputs = $('#paymentInfo input[type="text"]:not(.uneditable)');
            var selects = $('#paymentInfo select:not(.uneditable)');
            var textareas = $('#paymentInfo textarea:not(.uneditable)');
            toggleInputOrSelectElement(viewMode,inputs);
            toggleInputOrSelectElement(viewMode,selects);
            toggleInputOrSelectElement(viewMode,textareas);
    
            toggleButtons(viewMode,$('#add-paymentrequest-link'));
            toggleButtons(viewMode,$('#cancelEditButton'));
            toggleButtons(viewMode,$('#save'));
            toggleButtons(viewMode,$('#saveAndAddNew'));
            toggleButtons(!viewMode,$('#editButton'));
            
            var lineItemInputs = $('#paymentLineItems input');
            var lineItemSelects = $('#paymentLineItems select');
            for(var i = 0; i < lineItemInputs.length; i++) {
                lineItemInputs[i].readonly = viewMode;
                lineItemInputs[i].disabled = viewMode;
            }
            for(var i = 0; i < lineItemSelects.length; i++) {
                lineItemSelects[i].readonly = viewMode;
                lineItemSelects[i].disabled = viewMode;
            }
        }
</script>
<div id="editPaymentrequestDiv">
    <form:form name="editPaymentrequestForm" id="editPaymentrequestForm" cssClass="main_form" action="processPaymentrequest.do?id=${paymentrequest.id}" method="post" modelAttribute="paymentrequest">
        <form:hidden path="id" />
        <form:checkbox id="sixFiveSeventyVerify" path="sixFiveSeventyVerify" cssClass="hiddenElement"/>
        <div class="form_head">
            <a href="#" class="close-button gray_btn floatR" tabindex="-1">Close Form</a>
            <div class="floatL" style="margin-top: 5px; width: 800px;">
                <a href="#" id="btnSignatureAllUnpaid" class="blue_btn" onclick="return false;" tabindex="-1">Signature Selection All Unpaid</a>
                <a href="#" id="btnOver30days" class="blue_btn" onclick="return false;" tabindex="-1">Over 30 days past due</a>
                <a href="#" id="btnOutstandingWireTransfers" class="blue_btn" onclick="return false;" tabindex="-1">Outstanding Wire Transfers</a>
                <a href="#" id="btnSignatureSelection" class="blue_btn" onclick="return false;" tabindex="-1">Signature Selection Never Selected</a>
            </div>
            <div class="floatL" style="margin-top: 5px; width: 800px;">
              <a href="#" id="instructions-link" class="blue_btn" paymentrequestId="${paymentrequest.id}" tabindex="-1"><spring:message code="editPaymentrequest.label.instructions" /></a>
              <a href="#" id="printPaymentRequest" class="blue_btn"  style="display: none;" onclick="return false;" tabindex="-1">&nbsp;</a>
              <a href="#" id="printWireForm" class="uneditable blue_btn" tabindex="-1"><spring:message code="editPaymentrequest.label.printWireForm" /></a>
            </div>            
            <br class="clear" />
        </div>
        <div class="form_cont">
            <table id="paymentInfo" class="fiveColTable" width="100%" cellspacing="1" cellpadding="0">
              <tr>
                <td colspan="5" style="font-size: 16pt; text-align: center;"><spring:message code="editPaymentrequest.heading.availableAction" /></td>
              </tr>
              <tr>
                <td colspan="5" style="text-align: center;">
                <c:choose>
                  <c:when test="${canCancelStatus}">
                    <sj:submit id="cancelPaymentStatusButton" cssClass="uneditable" target="editPaymentrequestDiv" key="editPaymentrequest.label.cancel" tabindex="-1"/>
                  </c:when>
                  <c:otherwise>
                    <sj:submit id="cancelPaymentStatusButton" cssClass="uneditable" target="editPaymentrequestDiv" key="editPaymentrequest.label.cancel" attr="disabled='disabled'" tabindex="-1"/>
                  </c:otherwise>
                </c:choose>
                <c:choose>
                  <c:when test="${canRejectStatus}">
                    <sj:submit id="rejectPaymentStatusButton" target="editPaymentrequestDiv" cssClass="uneditable" key="editPaymentrequest.label.reject" validate="true" tabindex="-1" cssStyle="visibility: hidden; margin: 0; padding: 0; border: 0; float: left; width: 1px;"/>
                    <input type="button" id="dummyRejectStatusButton" class="uneditable" value='<spring:message code="editPaymentrequest.label.reject" />' tabindex="-1"/>
                  </c:when>
                  <c:otherwise>
                    <input type="button" id="dummyRejectStatusButton" class="uneditable"  disabled="disabled" value='<spring:message code="editPaymentrequest.label.reject" />' tabindex="-1"/>
                  </c:otherwise>
                </c:choose>
                <c:if test="${!empty nextButtonValue}">
                  <c:choose>
                    <c:when test="${disableNextButtonValue}">
                      <sj:submit id="nextActionButton" cssClass="uneditable" target="content" value="${nextButtonValue}" nameKey="name.button.nextaction" validate="true" attr="disabled='disabled'"/>
                    </c:when>
                    <c:otherwise>
                      <sj:submit id="nextActionButton" cssClass="uneditable" target="content" value="${nextButtonValue}" nameKey="name.button.nextaction" validate="true" />
                    </c:otherwise>
                  </c:choose>
                </c:if>
                </td>
              </tr>
              <tr class="row">
                 <td colspan="5" style="text-align: center;"><%@ include file="/common/messages.jsp"%></td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.paymentIdentifiedInformation" /></td>
                <td class="input-field">
                  <form:input path="id" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="-1"/>
                  <form:errors path="id" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.dateToFinanace" /></td>
                <td class="input-field">
                <form:input path="dateToFinanace" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="dateToFinanace" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="label.originator" /></td>
                <td class="input-field">
                <input type="text" value="${paymentrequest.createdBy }" class="input-full-width text_grey uneditable" readonly="readonly" tabindex="-1" />
                <form:errors path="createdBy" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.dateforwardedforsignature" /></td>
                <td class="input-field">
                <form:input path="dateforwardedforsignature" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="dateforwardedforsignature" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.datecreated" /></td>
                <td class="input-field">
                <form:input disabled="true" path="creationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.datesubmittedforpayment" /></td>
                <td class="input-field">
                <form:input path="datesubmittedforpayment" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="datesubmittedforpayment" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.responsibleNextAct" /></td>
                <td class="input-field">
                <form:input path="currentlyresponsible" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="-1"/>
                <form:errors path="currentlyresponsible" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.datepaid" /></td>
                <td class="input-field">
                <form:input path="datePaid" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="datePaid" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label" style="color: red"><spring:message code="editPaymentrequest.label.currentStatus" /></td>
                <td class="input-field">
                <span style="color:red"><form:input path="statusCode" cssClass="input-full-width text_grey uneditable" disabled="true" tabindex="-1"/></span>
                <form:errors path="statusCode" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.daterejected" /></td>
                <td class="input-field">
                <form:input path="dateRejected" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="dateRejected" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.payee" /></td>
                <td class="input-field">
                <form:select path="payeeId" cssStyle="width: 74%;" cssClass="input-full-width-req text_grey" disabled="true" tabindex="1">
                  <form:option value="" label="Select" />
                  <form:options items="${payeeList}" itemValue="id" itemLabel="payeeName" />
                </form:select>
                <form:hidden path="payeeDesc"/>
                <sj:submit id="add-paymentrequest-link" nameKey="editPaymentrequest.button.addEditPayee" cssClass="gray_btn cancel" target="editPaymentrequestDiv" key="label.edit" tabindex="-1"/>
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.rejectedreason" /></td>
                <td class="input-field">
                <form:textarea path="reasonrejected" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.payeeAddress" /></td>
                <td class="input-field">
                <input id="payeeAddress" type="text" class="text_grey uneditable" readonly="readonly" tabindex="-1" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.dateresubmitted" /></td>
                <td class="input-field">
                <form:input path="dateResubmitted" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="dateResubmitted" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label">Source Document Type</td>
                <td class="input-field">
                <form:select path="sourceDocumentType" cssClass="input-full-width text_grey" disabled="true" tabindex="2">
                  <form:option value="Invoice" label="Invoice" />
                  <form:option value="Account" label="Account" />
                  <form:option value="Contract" label="Contract" />
                  <form:option value="Reference #" label="Reference #" />
                </form:select>
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.datecancelrequested"/></td>
                <td class="input-field">
                <form:input path="dateCancelRequested" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="dateCancelRequested" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.invoiceno" /></td>
                <td class="input-field">
                <form:input path="invoicenumber" cssClass="input-full-width  text_grey" disabled="true" tabindex="3"/>
                <form:errors path="invoicenumber" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.datecancelled" /></td>
                <td class="input-field">
                <form:input path="dateCancelled" cssClass="input-full-width text_grey uneditable"  disabled="true" tabindex="-1"/>
                <form:errors path="dateCancelled" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.invoiceRequestDate" /></td>
                <td class="input-field">
                <form:input path="invoiceRequestDate" cssClass="input-full-width text_grey" disabled="true" tabindex="4"/>
                <form:errors path="invoiceRequestDate" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.checkConfirmNumber" /></td>
                <td class="input-field">
                <form:input path="paymentConfirmationNumber" cssClass="input-full-width text_grey" disabled="true" tabindex="9"/>
                <form:errors path="paymentConfirmationNumber" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.paymentrequesttype" /></td>
                <td class="input-field">
                <form:select path="paymentTypeId" cssClass="input-full-width-req text_grey" disabled="true" tabindex="5">
                  <form:option value="" label="Select" />
                  <form:options items="${paymenttypeList}" itemValue="id" itemLabel="paymenttypename" />
                </form:select>
                <form:errors path="paymentTypeId" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.comments" /></td>
                <td class="input-field">
                <form:input path="comments" cssClass="input-full-width text_grey" disabled="true" tabindex="10"/>
                <form:errors path="comments" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.paymentmethod" /></td>
                <td class="input-field"><form:select path="paymentMethod" cssClass="input-full-width-req text_grey" disabled="true" tabindex="6">
                  <form:option value="" label="Select" />
                  <form:option value="Wire" label="Wire" />
                  <form:option value="Check" label="Check" />
                  <%-- Commented due to ERR-24 
                  <form:option value="Other" label="Other" />
                  --%>
                </form:select>
                <form:errors path="paymentMethod" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="editPaymentrequest.label.specialInstructions" /></td>
                <td class="input-field">
                <form:input path="specialInstructions" cssClass="input-full-width text_grey" disabled="true" tabindex="8"/>
                <form:errors path="specialInstructions" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.purposeOfExpenditure" /></td>
                <td class="input-field">
                <form:input path="purposeOfExpenditure" cssClass="input-full-width-req text_grey" dir="true" tabindex="7"/>
                <form:errors path="purposeOfExpenditure" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="label.updatedBy" /></td>
                <td class="input-field">
                <input type="text" value="${paymentrequest.updatedBy }" class="input-full-width text_grey uneditable" readonly="readonly" tabindex="-1"/>
                <form:errors path="updatedBy" cssClass="error" />
                </td>
              </tr>
              <tr>
                <td class="label"><spring:message code="editPaymentrequest.label.amount" /></td>
                <td class="input-field">
                <form:hidden path="amount" cssClass="input-full-width text_grey uneditable" />
                <input type="text" value="&nbsp;" readonly="readonly"  id="amountLabel" class="text_grey uneditable" tabindex="-1" style="font-size: 2em;"/>
                <form:errors path="amount" cssClass="error" />
                </td>
                <td class="fiveColSpacer">&nbsp;</td>
                <td class="label"><spring:message code="label.updationDate" /></td>
                <td class="input-field">
                <form:input disabled="true" path="updationDate" cssClass="input-full-width text_grey uneditable" tabindex="-1"/>
                <form:errors path="updationDate" cssClass="error" />
                </td>
              </tr>
            </table>
            <div id="paymentLineItems">
            </div>
            <div style="text-align: center;">
                  <c:choose>
                    <c:when test="${empty canEdit || !canEdit}">
                      <input id="editButton" type="button" class="gray_btn" value="Edit" disabled="disabled" tabindex="-1">
                    </c:when>
                    <c:otherwise>
                      <input id="editButton" type="button" class="blue_btn" value="Edit" tabindex="-1">
                    </c:otherwise>
                  </c:choose>
                  <input id="cancelEditButton" type="button" class="gray_btn" value="Cancel Edit" disabled="disabled" tabindex="-1">
                  <input id="save" type="button" class="gray_btn" disabled="disabled" value='<spring:message code="editPaymentrequest.button.save" />' tabindex="-1"/>
                  <sj:submit id="doSave" cssClass="hiddenSubmitButton" target="editPaymentrequestDiv" key="editPaymentrequest.button.save" validate="true" tabindex="-1"/>                    
                <br />
                <br />            
            </div>
        </div>
    </form:form>
    <script type="text/javascript">
        $(document).ready(function() {
            $('table.tablesorter').tablesorter({
                widgets : [ 'zebra' ],
                sortList : [ [ 0, 0 ], [ 1, 0 ] ],
                headers : {
                    10 : {
                        sorter : false
                    }
                }
            });

            $('.edit-paymentrequestaward-link').click(function() {
                loadDiv('content', 'showEditPaymentrequest.do?id=' + $(this).attr('paymentrequestawardId'));
            });
        });
    </script>
</div>
